package com.yanqu.road.entity.activity.commonteam.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.Objects;

@FieldTypeAnnotation(tableName = "t_c_common_team_member", desc = "通用组队-队伍成员表")
public class CommonTeamUserData extends DataObject {

    /**
     * 活动ID
     */
    @FieldTypeAnnotation(select = true, update = true, isIndex = true)
    private int activityId;

    /**
     * 分组ID
     */
    @FieldTypeAnnotation(desc = "分组ID")
    private int groupId;

    /**
     * 队伍ID
     */
    @FieldTypeAnnotation(desc = "队伍ID")
    private int teamId;

    /**
     * 用户ID
     */
    @FieldTypeAnnotation(desc = "用户ID")
    private long userId;

    /**
     * 名称
     */
    @FieldTypeAnnotation(desc = "名称")
    private String userName;

    /**
     * 区服ID
     */
    @FieldTypeAnnotation(desc = "区服ID")
    private long serverId;

    /**
     * 实力分数
     */
    @FieldTypeAnnotation(desc = "实力分数")
    private long score;

    /**
     * 最近加入队伍的时间
     */
    @FieldTypeAnnotation(desc = "最近加入队伍的时间")
    private long lastJoinTeamTime;

    /**
     * 最近创建队伍的时间
     */
    @FieldTypeAnnotation(desc = "最近创建队伍的时间")
    private long lastCreateTeamTime;

    @FieldTypeAnnotation(desc = "主动离队时间")
    private long selfLeaveTeamTime;

    /**
     * 创建时间
     */
    @FieldTypeAnnotation(desc = "创建时间")
    private long createTime;

    @FieldTypeAnnotation(desc = "扩展参数")
    private String extendsParam = "";

    public CommonTeamUserData() {}

    public CommonTeamUserData(int activityId, int groupId, long userId, String userName, long serverId, long score) {
        this.activityId = activityId;
        this.groupId = groupId;
        this.teamId = 0;
        this.userId = userId;
        this.userName = userName;
        this.serverId = serverId;
        this.score = score;
        this.lastJoinTeamTime = 0;
        this.lastCreateTeamTime = 0;
        this.selfLeaveTeamTime = 0;
        this.createTime = System.currentTimeMillis();
        setInsertOption();
    }

    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public int getActivityId() {
        return activityId;
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        if (this.groupId != groupId) {
            this.groupId = groupId;
            setOp(DataStatus.Update);
        }
    }

    public void setTeamId(int teamId) {
        if (this.teamId != teamId) {
            this.teamId = teamId;
            setOp(DataStatus.Update);
        }
    }

    public int getTeamId() {
        return teamId;
    }

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserName(String userName) {
        if (!Objects.equals(this.userName, userName)) {
            this.userName = userName;
            setOp(DataStatus.Update);
        }
    }

    public String getUserName() {
        return userName;
    }

    public void setServerId(long serverId) {
        if (this.serverId != serverId) {
            this.serverId = serverId;
            setOp(DataStatus.Update);
        }
    }

    public long getServerId() {
        return serverId;
    }

    public void setScore(long score) {
        if (this.score != score) {
            this.score = score;
            setOp(DataStatus.Update);
        }
    }

    public long getScore() {
        return score;
    }

    public long getLastJoinTeamTime() {
        return lastJoinTeamTime;
    }

    public void setLastJoinTeamTime(long lastJoinTeamTime) {
        if (this.lastJoinTeamTime != lastJoinTeamTime) {
            this.lastJoinTeamTime = lastJoinTeamTime;
            setOp(DataStatus.Update);
        }
    }

    public long getLastCreateTeamTime() {
        return lastCreateTeamTime;
    }

    public void setLastCreateTeamTime(long lastCreateTeamTime) {
        if (this.lastCreateTeamTime != lastCreateTeamTime) {
            this.lastCreateTeamTime = lastCreateTeamTime;
            setOp(DataStatus.Update);
        }
    }

    public void setCreateTime(long createTime) {
        if (this.createTime != createTime) {
            this.createTime = createTime;
            setOp(DataStatus.Update);
        }
    }

    public long getCreateTime() {
        return createTime;
    }

    public long getSelfLeaveTeamTime() {
        return selfLeaveTeamTime;
    }

    public void setSelfLeaveTeamTime(long selfLeaveTeamTime) {
        if (this.selfLeaveTeamTime != selfLeaveTeamTime) {
            this.selfLeaveTeamTime = selfLeaveTeamTime;
            setOp(DataStatus.Update);
        }
    }

    public String getExtendsParam() {
        return extendsParam;
    }

    public void setExtendsParam(String extendsParam) {
        if(!Objects.equals(this.extendsParam, extendsParam)) {
            this.extendsParam = extendsParam;
            setUpdateOption();
        }
    }
}
